<?php
class ChannelListAction extends Action{
	
	public function main(){
		//$Channels = '';
		$classid = $this->_request['ClassID'];
		if ($classid) {
			$obj = new ChannelClassRelation();
			$classlist = $obj->getChannelIDByClassID($classid);
			$Channels = implode(",", $classlist);
		}


		$obj = new  ChannelInfoDAO();
		$selected = new Selected();
		if (isset($Channels)){
			$ret = $obj->getListByID($Channels);
		}else{
			$ret = $obj->getList();
		}
		//debug($ret);
		if ($ret) {
			# code...
			for ($i=0; $i < count($ret); $i++) { 
				$ret[$i]['ChannelEnableShow'] = $selected->getVal("ChannelEnable",$ret[$i]['ChannelEnable']);
				$ret[$i]['ChannelDisplayShow'] = $selected->getVal("ChannelDisplay",$ret[$i]['ChannelDisplay']);
				$ret[$i]['ChannelDisplayOrder'] = $selected->getVal("ChannelDisplayOrder",$ret[$i]['ChannelDisplayOrder']);
				$ret[$i]['list'] =$this->_request['list'];
				$ret[$i]['ClassID'] =$this->_request['ClassID'];
			}
		}

		$this->_response['ret'] = $ret;
		$this->_response['list'] =$this->_request['list'];
		//debug($this->_response['ret']);
	}

}